<?php

class Main_Resource_Address extends WOW_Model_Resource_Db_Table_Abstract implements
Main_Resource_Address_Interface
{
    protected $_name = 'user_addresses';
    protected $_primary = 'address_id';
    protected $_rowClass = 'Main_Resource_Address_Item';


    public function getAddressById($id)
    {
        return $this->find($id)->current();
    }

    public function getUserAddress($userid)
    {
        $select = $this->select();
        $select->where('uid = ?', $userid);
        
        return $this->fetchAll($select);
    }

    public function getUserCorrespondanceAddress($userid)
    {
        $select = $this->select();
        $select->where( 'uid = ?', $userid );
        $select->where( 'isCorrespondance = ?', 1 );

        return $this->fetchRow($select);
    }

    public function getUserEmergencyAddress($userid)
    {
        $select = $this->select();
        $select->where( 'uid = ?', $userid );
        $select->where( 'IsEmergency = ?', 1 );

        return $this->fetchRow($select);
    }


}
?>
